using micromsg;
using MicroMsg.Common.Event;
using MicroMsg.Common.Utils;
using MicroMsg.Manager;
using MicroMsg.Protocol;
using MicroMsg.Scene;
using MicroMsg.Storage;
using System;
namespace MicroMsg.Plugin.Sns.Scene
{
	public class NetSceneSnsTagOption : NetSceneBaseEx<SnsTagOptionRequest, SnsTagOptionResponse, SnsTagOptionRequest.Builder>
	{
		private const string TAG = "NetSceneSnsTagOption";
		private static NetSceneSnsTagOption _mInstance;
		public static NetSceneSnsTagOption Instance
		{
			get
			{
				if (NetSceneSnsTagOption._mInstance == null)
				{
					NetSceneSnsTagOption._mInstance = new NetSceneSnsTagOption();
				}
				return NetSceneSnsTagOption._mInstance;
			}
		}
		public bool doScene(SnsTagOptionOpCode opCode, ulong tagId, string tagName)
		{
			base.beginBuilder();
			this.mBuilder.BaseRequest = NetSceneBase.makeBaseRequest(0);
			this.mBuilder.OpCode = (uint)opCode;
			this.mBuilder.TagId = tagId;
			this.mBuilder.TagName = tagName;
			this.mSessionPack.mCmdID = 114;
			return base.endBuilder();
		}
		protected override void onFailed(SnsTagOptionRequest request, SnsTagOptionResponse response)
		{
			Log.smethod_1("NetSceneSnsTagOption", "send request failed");
			EventCenter.postEvent(EventConst.ON_NETSCENE_SNS_TAG_OP_ERR, request.TagId, null);
		}
		protected override void onSuccess(SnsTagOptionRequest request, SnsTagOptionResponse response)
		{
			RetConst ret = (RetConst)response.BaseResponse.Ret;
			if (ret != RetConst.MM_OK)
			{
				EventCenter.postEvent(EventConst.ON_NETSCENE_SNS_TAG_OP_ERR, request.TagId, null);
				return;
			}
			if (request.OpCode == 3u)
			{
				StorageMgr.snsTag.method_5(request.TagId.ToString("X16"));
				EventCenter.postEvent(EventConst.ON_NETSCENE_SNS_TAG_OP_SUCCESS, request.TagId, null);
				return;
			}
			SnsTagInfo item = SnsInfoMgr.toSnsTagInfo(response.SnsTag);
			StorageMgr.snsTag.update(item);
			EventCenter.postEvent(EventConst.ON_NETSCENE_SNS_TAG_OP_SUCCESS, response.SnsTag.TagId, null);
		}
	}
}
